/* api */
import { getSettingRoleList } from "@src/api/SettingApi"
/* hooks */
import { useLoading } from "@hooks/useLoading"
/* model */
import Page from "@model/Page"
import Role from "@model/entity/Role/Role"
import MsgModel from "@model/MsgModel"
/* vue */
import { ref, Ref } from "vue"
/* util */
import { message } from "@src/util/message"
/* locales */
import { t } from "@src/locales"

function useBizRoleSelect() {

}

function useBizRoleSelectFetchRoleList() {
  
  // 加载状态
  const { loading, showLoading, hideLoading } = useLoading()
  
  const roleList: Ref<Role[]> = ref([])
  
  const fetchRoleList = (params: Partial<Page>) => {
    
    showLoading()
    
    return (
      getSettingRoleList(params).then(result => {
        
        roleList.value = result?.list || []
        
        return roleList.value
        
      }).finally(() => {
        hideLoading()
      })
    )
  }
  
  return {
    roleList,
    loading,
    fetchRoleList
  }
  
}

export {
  useBizRoleSelectFetchRoleList
}
